//
//  ViewController.m
//  02-UIViewContronller
//
//  Created by 王道林 on 16/7/15.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "ViewController.h"
#import "PresentViewController.h"

@interface ViewController ()
@property (nonatomic, strong) UIView *subView;
@end

@implementation ViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        //不要再这个方法中,加载视图
        //
    }
    return self;
}



// loadview 加载UIViewController中的View
// UINavigation  UITableVviewController  在loadview中给重写赋值了
- (void)loadView
{
    [super loadView];
    NSLog(@"loadview");
   // 改变self.view
}


// view  已经  加载
//所有自定义视图的创建
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor redColor];
    NSLog(@"viewdidload");
    
    
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    PresentViewController *present = [[PresentViewController alloc] init];
    
    // 翻页特效, 动画
    present .modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    // 模态推出 下一界面
    [self presentViewController:present animated:YES completion:nil];
}




// 注意: init loaView viewDidLoad  只执行一次

// 视图将要出现时
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

// 视图将要消失时
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

// 视图将要消失时
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

// 视图已经消失

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}




//懒加载
- (UIView *)subView
{
    if (_subView == nil) {
        _subView = [UIView new];
    }
    return _subView;
}



// 接收到内存警告时, 执行的方法
- (void)didReceiveMemoryWarning {
    // 从父类继承过来的方法中得内存警告的打印
    [super didReceiveMemoryWarning];
    //释放部分内存资源
    // 把未显示在屏幕上的资源置空
    // Dispose of any resources that can be recreated.
}

@end
